<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
%>
<!--只在模块名下面有效 -->
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>操作日志</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <style>
        .visit_rec_detail_win {
            text-align: left !important;
            padding: 10px 25px 25px 25px;
        }
    </style>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div id="ligergridDB" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var gridDB = null;
    var pageInApp = {}; // to 下一级子窗口 接口
    var queryFlag = '${queryFlag}'; //只查询列表
    var pageInTab = null;
    var _dataTypCd = '${dataTypCd}';
    var _opObjTyp = '${opObjTyp}';
    var loadedTabs = [];
    $(function () {
        initTab();
        initGridDB(); //初始化待办列表
        $("#searchBar").ligerForm();
        $("#searchBtn").click(function (event) {
            reloadGrid();
        });
        $('#closeAttachmentsView').click(function () {
            closeAttachmentsView();
        });
    });

    //重新加载GRID
    function reloadGrid() {
        var form = new liger.get("searchBar");
        var data = form.getData();
        for (name in data) {
            console.log('name:' + name + ',data:' + data[name]);
            gridDB.setParm(name, data[name]);
        }
        ;
        gridDB.reload();
    }

    //初始化列表
    function initGridDB() {
        $("#ligergridDB").ligerGrid({
            url: '<%=path%>/mongo/splRelDataOpRec/initList.do?dataId=' + '${dataId}' + '&opObjTyp=${opObjTyp}' + '&dataTypCd=' + _dataTypCd,
            method: 'get',
            columns: [
                {
                    display: '操作数据主键',
                    name: 'pkId',
                    width: 150,
                    enabledSort: false,
                    hide: true
                },
                {
                    display: '业务数据主键',
                    name: 'dataId',
                    width: 150,
                    enabledSort: false,
                    hide: true
                },
                {
                    display: '业务数据名称',
                    name: 'dataNm',
                    width: 150,
                    enabledSort: false
                },
                {
                    display: '版本号',
                    name: 'verNum',
                    width: 150,
                    enabledSort: false
                },
                {
                    display: '操作类型',
                    name: 'opTypCdNm',
                    width: 100,
                    enabledSort: false
                },
                {
                    display: '操作数据类型',
                    name: 'dataTypCd',
                    width: 100,
                    enabledSort: false,
                    hide: true
                },
                {
                    display: '操作对象分类',
                    name: 'opObjTyp',
                    width: 100,
                    enabledSort: false,
                    hide: true
                },
                {
                    display: '操作原因',
                    name: 'opDesc',
                    minWidth: 100,
                    enabledSort: false,
                    hide: true
                },
                {
                    display: '操作前后差异信息',
                    name: 'compareDiffInfo',
                    minWidth: 300,
                    enabledSort: false
                },
                {
                    display: '操作人',
                    name: 'crtUsrNm',
                    minWidth: 150,
                    enabledSort: false
                },
                {
                    display: '操作时间',
                    name: 'crtTm',
                    minWidth: 150,
                    render: function (rowdata, index, value) {
                        return renderDate2(rowdata, index, value);
                    }
                },
                {
                    display: '操作前数据信息',
                    //name : 'opBeforeData',
                    minWidth: 300,
                    enabledSort: false,
                    hide: true,
                    render: function (rowdata, rowindex, value) {
                        var _msg = rowdata.opBeforeData;
                        var h1 = '';
                        if (_msg) {
                            _msg = escape(_msg);
                            h1 = '<span onclick="showMessage(\'' + _msg + '\')" title="' + _msg + '"><a class="sq-button-hasicon" href="javascript:;">' + rowdata.opBeforeData + '</a></span>';
                        }
                        return h1;
                    }
                },
                {
                    display: '操作后数据信息',
                    //name : 'opAfterData',
                    minWidth: 300,
                    enabledSort: false,
                    hide: true,
                    render: function (rowdata, rowindex, value) {
                        var _msg = rowdata.opAfterData;
                        var h1 = '';
                        if (_msg) {
                            _msg = escape(_msg);
                            h1 = '<span onclick="showMessage(\'' + _msg + '\')" title="' + _msg + '"><a class="sq-button-hasicon" href="javascript:;">' + rowdata.opAfterData + '</a></span>';
                        }
                        return h1;
                    }
                }
            ],
            pageSize: 10,
            pageSizeOptions: [10, 20, 30, 40, 50, 100], //按照自己的喜好选择不同的页面显示条数
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            rowHeight: '100%',
            width: '100%',
            height: '100%',
            heightDiff: -30,
            //checkbox : true,
            rownumbers: true,
            frozenRownumbers: false, //控制rownumbers自适应高度
            onAfterShowData: function () {
                $(".gridTip").grid_ligerTip();
                SetIframe_height();
            }
        });
        gridDB = liger.get("ligergridDB");
        gridDB.setHeight(100);
        gridDB.options.isSingleCheck = true;
    }

    <!-- 查看详情 -->
    function showMessage(msg) {
        $.ligerDialog.SQalert({
            SQ_showButtons: true,
            width: 500,
            content: unescape(msg)
        });
    }

    //格式化时间
    function renderDate2(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, "yyyy-MM-dd hh:mm");
        }
        return dateStr;
    }

    function clearBtn() {
        clearLigerForm("searchBar");
        liger.get("buOrgCd").clear();//清空树
    }

    function iframeResize() {
        if (parent.mainApp) {
            parent.mainApp.parentTab.onResize();
        }
    }

    //初始化Tab页
    function initTab() {
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onAfterSelectTabItem: function (tabid) {
                currTab = tabid; //赋值是哪个Tab页面
                if (loadedTabs.indexOf(tabid) < 0) {
                    loadedTabs.push(tabid);
                    switch (tabid) {
                        case "tabB":
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/bizflow/rskUsrAchLog/toMyAchievementsPage.do");
                            break;
                    }
                }
                ;
                SetIframe_height();
            }
        });

        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    }
</script>

</body>
</html>
